package com.lc.adapter;

import java.util.ArrayList;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.example.japaneseapp.R;
import com.lc.listword.NewWord;

public class ListWordAdapter extends ArrayAdapter<NewWord> {
	Activity context = null;
	ArrayList<NewWord> listWord = null;
	int layoutId;

	public ListWordAdapter(Activity context, int layoutId,
			ArrayList<NewWord> listWord) {
		super(context, layoutId, listWord);

		this.context = context;
		this.layoutId = layoutId;
		this.listWord = listWord;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View listView;
		if (convertView == null) {
			LayoutInflater inflater = context.getLayoutInflater();
			listView = inflater.inflate(R.layout.item_newword, null);
		} else {
			listView = convertView;
		}
		TextView tvJpWord = (TextView) listView.findViewById(R.id.JapWord);
		TextView tvVnWord = (TextView) listView.findViewById(R.id.VnWord);
		NewWord newword = listWord.get(position);
		tvJpWord.setText(newword.getJpWord());
		tvVnWord.setText(newword.getVnWord());
		return listView;
	}

}
